package com.windoent.yugioh.ui.fragment.saishi.baoming;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.baidu.mobstat.StatService;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import com.windoent.yugioh.R;
import com.windoent.yugioh.adapter.banner.ImageAdapter;
import com.windoent.yugioh.adapter.brvah.BaoMingAuthCaiPanAdapter;
import com.windoent.yugioh.adapter.brvah.BaoMingAuthCaiPanMainAdapter;
import com.windoent.yugioh.base.BaseFragment;
import com.windoent.yugioh.bean.CaiPanListData;
import com.windoent.yugioh.bean.GameStatusRoleBean;
import com.windoent.yugioh.bean.GeneralBean;
import com.windoent.yugioh.bean.eventbus.FragmentActivityMessageEvent;
import com.windoent.yugioh.constants.Constants;
import com.windoent.yugioh.http.PhoneLive;
import com.windoent.yugioh.ui.activity.saishi.SearchBaoMingCaiPanActivity;
import com.windoent.yugioh.utils.BaseMethod;
import com.windoent.yugioh.utils.BaseUtils;
import com.windoent.yugioh.utils.ToastUtils;
import com.windoent.yugioh.widget.SearchView;
import com.windoent.yugioh.widget.dialog.ExitGameReasonDialog;
import com.windoent.yugioh.widget.dialog.SucessFailAutoDismissDialog;
import com.windoent.yugioh.widget.dialog.SureNotDialog;
import com.youth.banner.Banner;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;

/**
 * author : robert
 * date   : 2021/5/17 14:14
 * desc   :报名审核裁判
 */
public class BaoMingAuthCaiPanFragment extends BaseFragment {
    private Button mBtnGetCode;
    private Button mBtnGetCodeNoAll;
    private Banner mBanner;
    private SearchView mSearch;
    private RecyclerView mRecyclerViewMain;
    private RecyclerView mRecyclerView;
    private ImageAdapter bannerAdapter;
    private LinearLayout mLlNoJudge;
    private LinearLayout mLlNoMainJudge;
    private SmartRefreshLayout mSmartLayout;
    private LinearLayout mLlNoJudgeMainJudge;
    private RelativeLayout mRlJudge;


    private BaoMingAuthCaiPanMainAdapter topCaiPanListAdapter;
    private BaoMingAuthCaiPanAdapter caiPanAdapter;
    private int status;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_saishi_baoming_auth_caipan;
    }

    @Override
    protected void initEventAndData() {
        initView();
        initData();
        initListener();
    }

    private void initListener() {
        mSearch.setListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //搜索
                Intent intent = new Intent(mContext, SearchBaoMingCaiPanActivity.class);
                intent.putExtra("id", id);
                startActivity(intent);
            }
        });
        mBtnGetCode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (status == 2) {
                    dianjiaStartGame(id);
                } else if (status == 1) {
                    ToastUtils.showText(getString(R.string.string_nt_immediately_start));
                } else {
                    ToastUtils.showText(getString(R.string.string_already_start));
                }
            }
        });
        mBtnGetCodeNoAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //店家申请主裁判
                dianjiaApplyMainJudge();
            }
        });
    }

    //店家申请主裁判
    private void dianjiaApplyMainJudge() {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setTvContent(getString(R.string.string_sure_self_main_judge_games_warn));
        dialog.setYesStr(getString(R.string.string_sure));
        dialog.setNoStr(getString(R.string.dl_cancel));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                caipanDianjiaApplay();
            }
        });
        dialog.show();
    }

    //申请主裁判
    private void caipanDianjiaApplay() {
        showLoadingDialog("");
        PhoneLive.caipanDianjiaApplay(getUserToken(), id, "1", new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int idres) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_caipan_apply_victory)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    fresh(id);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_caipan_apply_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //店家开启比赛
    private void dianjiaStartGame(String id) {
        showLoadingDialog("");
        PhoneLive.dianjiaStartGame(getUserToken(), id, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int idres) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        if (fromJson.getCode() == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(fromJson.getMsg(), getString(R.string.string_start_game_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    status = 3;
                                    mBtnGetCode.setSelected(true);
                                    mBtnGetCode.setText(getString(R.string.string_already_start));
                                    fresh(id);
                                }
                            });
                        } else {
                            String msg = fromJson.getMsg();
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_start_game_fail), msg);
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //审核通过
    private void showAuthDialog(int userID, String type) {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setTvContent(getString(R.string.string_sure_auth_pass_warn));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                dianjiaPassCaiPan(id, userID, type);
            }
        });
        dialog.show();
    }

    //店家审核通过裁判
    private void dianjiaPassCaiPan(String id, int userID, String type) {
        showLoadingDialog("");
        PhoneLive.dianjiaPassCaiPan(getUserToken(), id, userID, type, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int rid) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_sppaly_judge_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    fresh(id);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_sppaly_judge_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }

            }
        });
    }

    private void initData() {
        initMainAdapter();
        initAdapter();
        initBanner();
    }

    private void initBanner() {
        bannerAdapter = new ImageAdapter(null);
        mBanner.setAdapter(bannerAdapter)
                .addBannerLifecycleObserver(this);//添加生命周期观察者
    }

    private void initAdapter() {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        caiPanAdapter = new BaoMingAuthCaiPanAdapter();
        caiPanAdapter.setEmptyView(LayoutInflater.from(mContext).inflate(R.layout.recycler_view_empty, mRecyclerView, false));
        View footer = LayoutInflater.from(mContext).inflate(R.layout.recycler_view_empty_more, mRecyclerView, false);
        footer.findViewById(R.id.ll_more).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ToastUtils.showText("more");
            }
        });
        //adapter.addFooterView(footer);
        mRecyclerView.setNestedScrollingEnabled(false);
        mRecyclerView.setAdapter(caiPanAdapter);
        caiPanAdapter.addChildClickViewIds(R.id.tv_button, R.id.tv_button_set);
        caiPanAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull BaseQuickAdapter<?, ?> baseQuickAdapter, @NonNull View view, int position) {
                int id = view.getId();

                List<CaiPanListData.DataBean.RefereeBean> data = caiPanAdapter.getData();
                if (data != null) {
                    CaiPanListData.DataBean.RefereeBean umpireBean = data.get(position);
                    if (umpireBean != null) {
                        int status = umpireBean.getStatusId();
                        if (id == R.id.tv_button) {
                            if (status == 1) {
                                //通过
                                int uid = umpireBean.getId();
                                showAuthDialog(uid, "2");
                            } else if (status == 2) {
                                int userID = umpireBean.getUid();
                                showExitJudgeDialog(userID);
                            }
                        } else if (id == R.id.tv_button_set) {
                            int userID = umpireBean.getUid();
                            showMakeJudgeTopDialog(userID);
                        }
                    }
                }


            }
        });
    }

    //主裁判
    private void initMainAdapter() {
        mRecyclerViewMain.setLayoutManager(new LinearLayoutManager(mContext));
        topCaiPanListAdapter = new BaoMingAuthCaiPanMainAdapter();
        View footerMain = LayoutInflater.from(mContext).inflate(R.layout.recycler_view_empty_more, mRecyclerViewMain, false);
        footerMain.findViewById(R.id.ll_more).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ToastUtils.showText("more");
            }
        });
//        topCaiPanListAdapter.addFooterView(footerMain);
        mRecyclerViewMain.setNestedScrollingEnabled(false);
        mRecyclerViewMain.setAdapter(topCaiPanListAdapter);
        topCaiPanListAdapter.addChildClickViewIds(R.id.tv_button);
        topCaiPanListAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull BaseQuickAdapter<?, ?> baseQuickAdapter, @NonNull View view, int position) {
                List<CaiPanListData.DataBean.RefereeBean> data = topCaiPanListAdapter.getData();
                CaiPanListData.DataBean.RefereeBean refereeBean = data.get(position);
                if (refereeBean != null) {
                    int userID = refereeBean.getUid();
                    if (refereeBean.getStatusId() == 2) {
                        //退赛
                        showExitMainJudgeDialog(userID);
                    } else if (refereeBean.getStatusId() == 1) {
                        //去通过
                        int id = refereeBean.getId();
                        showAuthDialog(id, "1");
                    }
                }
            }
        });
    }

    //将裁判设为主裁判
    private void showMakeJudgeTopDialog(int userID) {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setTvContent(getString(R.string.string_sure_make_judge_top_warn));
        dialog.setYesStr(getString(R.string.string_sure));
        dialog.setNoStr(getString(R.string.dl_cancel));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                dianjiaMakeJudgeTop(userID);
            }
        });
        dialog.show();
    }

    //裁判设置为主裁判
    private void dianjiaMakeJudgeTop(int userID) {
        showLoadingDialog("");
        PhoneLive.dianjiaMakeJudgeTop(getUserToken(), id, userID + "", new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int idre) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_make_judge_top_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    //刷新列表
                                    fresh(id);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_make_judge_top_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }


    //踢出主裁判
    private void showExitMainJudgeDialog(int userID) {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setTvContent(getString(R.string.string_sure_exit_main_judge_games_warn));
        dialog.setYesStr(getString(R.string.string_exit_judge_main_still_play_warn));
        dialog.setNoStr(getString(R.string.dl_cancel));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                showExitReason(userID);
            }
        });
        dialog.show();
    }

    //踢出裁判
    private void showExitJudgeDialog(int userID) {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setTvContent(getString(R.string.string_sure_exit_judge_games_warn));
        dialog.setYesStr(getString(R.string.string_sure));
        dialog.setNoStr(getString(R.string.dl_cancel));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                showExitReason(userID);
            }
        });
        dialog.show();
    }


    private void showExitReason(int userID) {
        ExitGameReasonDialog dialog = new ExitGameReasonDialog(mContext);
        dialog.setOnclickListener(new ExitGameReasonDialog.onClickListener() {
            @Override
            public void onClick(String string) {
                dianjiaExitCaiPan(id, userID, string);
            }
        });
        dialog.show();
    }

    //店家退出裁判
    private void dianjiaExitCaiPan(String id, int userID, String remark) {
        showLoadingDialog("");
        PhoneLive.dianjiaExitCaiPan(getUserToken(), id, userID, remark, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int responseId) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_exit_judge_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    //刷新列表
                                    fresh(id);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_exit_judge_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    private void initView() {
        mBtnGetCode = (Button) mView.findViewById(R.id.btn_get_code);
        mBanner = (Banner) mView.findViewById(R.id.banner);
        mSearch = (SearchView) mView.findViewById(R.id.search);
        mRecyclerViewMain = (RecyclerView) mView.findViewById(R.id.recycler_view_main);
        mLlNoMainJudge = (LinearLayout) mView.findViewById(R.id.ll_no_main_judge);
        mRecyclerView = (RecyclerView) mView.findViewById(R.id.recycler_view);
        mLlNoJudge = (LinearLayout) mView.findViewById(R.id.ll_no_judge);
        mSmartLayout = (SmartRefreshLayout) mView.findViewById(R.id.smart_layout);
        mLlNoJudgeMainJudge = (LinearLayout) mView.findViewById(R.id.ll_no_judge_main_judge);
        mRlJudge = (RelativeLayout) mView.findViewById(R.id.rl_judge);
        mBtnGetCodeNoAll = (Button) mView.findViewById(R.id.btn_get_code_no_all);
    }


    public static BaoMingAuthCaiPanFragment newsInstance(String id, String response) {
        //创建 Bundle
        BaoMingAuthCaiPanFragment fragment = new BaoMingAuthCaiPanFragment();
        Bundle lBundle = new Bundle();
        lBundle.putString("id", id);
        lBundle.putString("response", response);
        fragment.setArguments(lBundle);
        return fragment;
    }

    @Override
    public void onResume() {
        super.onResume();
        if (getActivity() != null) {
            // 页面埋点
            StatService.onPageStart(getActivity(), "赛事报名中审核裁判tab");
        }
        getDetailsId();
    }

    @Override
    public void onPause() {
        super.onPause();
        if (getActivity() != null) {
            // 页面埋点
            StatService.onPageEnd(getActivity(), "赛事报名中审核裁判tab");
        }
    }

    private String id = "";

    //获取activity传值id
    private void getDetailsId() {
        Bundle bundle = getArguments();
        if (bundle != null) {
            id = bundle.getString("id");
            String response = bundle.getString("response");
            //下拉刷新
            initSmart(id);
            fresh(id);
        }
    }

    private void initSmart(String id) {
        mSmartLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                fresh(id);
            }
        });
    }

    private void fresh(String id) {
        getGameStatusRole(id);
    }

    //获取赛事状态角色
    private void getGameStatusRole(String id) {
        showLoadingDialog("");
        PhoneLive.getGameStatusRole(getUserToken(), id, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int idres) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    try {
                        if (BaseUtils.codeIs0(mContext, response)) {
                            GameStatusRoleBean json = gson.fromJson(response, GameStatusRoleBean.class);
                            if (json != null) {
                                GameStatusRoleBean.DataBean data = json.getData();
                                if (data != null) {
                                    String role = data.getRole();
                                    int statusid = data.getStatusid();
                                    if (statusid != 2 && statusid != 8) {
                                        //发送eventbus粘性事件
                                        FragmentActivityMessageEvent event = new FragmentActivityMessageEvent();
                                        event.setMessage(1);
                                        event.setRole(role);
                                        event.setStatusId(statusid);
                                        EventBus.getDefault().postSticky(event);
                                    } else if (statusid == 2) {
                                        getCaiPanListData(id);
                                    }
                                }
                            }
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //裁判列表
    private void getCaiPanListData(String id) {
        showLoadingDialog("");
        PhoneLive.getCaiPanListData(getUserToken(), id, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
                showTopCaiPan(false);
                showCaiPan(false);
                mSmartLayout.finishRefresh(false);
            }

            @Override
            public void onResponse(String response, int id) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    try {
                        if (BaseUtils.codeIs0(mContext, response)) {
                            mSmartLayout.finishRefresh(true);
                            CaiPanListData fromJson = gson.fromJson(response, CaiPanListData.class);
                            if (fromJson != null) {
                                CaiPanListData.DataBean data = fromJson.getData();
                                if (data != null) {
                                    List<String> banner = data.getBanner();
                                    if (bannerAdapter != null &&banner != null && banner.size() > 0) {
                                        mBanner.setVisibility(View.VISIBLE);
                                        bannerAdapter.setDatas(banner);
                                        bannerAdapter.notifyDataSetChanged();
                                    } else {
                                        mBanner.setVisibility(View.GONE);
                                    }
                                    status = data.getStatus();
                                    if (status != 2) {
                                        mBtnGetCode.setSelected(true);
                                        if (status == 1)
                                            mBtnGetCode.setText(getString(R.string.string_nt_immediately_start));
                                        else
                                            mBtnGetCode.setText(getString(R.string.string_already_start));
                                    } else {
                                        mBtnGetCode.setSelected(false);
                                        mBtnGetCode.setText(getString(R.string.string_start_games));
                                    }
                                    List<CaiPanListData.DataBean.RefereeBean> referee = data.getReferee();//主裁判审核
                                    List<CaiPanListData.DataBean.RefereeBean> umpire = data.getUmpire();
                                    if (referee != null && referee.size() > 0) {
                                        showTopCaiPan(true);
                                        topCaiPanListAdapter.setNewInstance(referee);
                                        caiPanAdapter.setShowSetTopJudge(false);
                                    } else {
                                        showTopCaiPan(false);
                                        caiPanAdapter.setShowSetTopJudge(true);
                                    }
                                    if (umpire != null && umpire.size() > 0) {
                                        showCaiPan(true);
                                        caiPanAdapter.setNewInstance(umpire);
                                    } else {
                                        showCaiPan(false);
                                    }
                                    if (referee == null && umpire == null) {
                                        mLlNoJudgeMainJudge.setVisibility(View.VISIBLE);
                                        mRlJudge.setVisibility(View.GONE);
                                    } else {
                                        mLlNoJudgeMainJudge.setVisibility(View.GONE);
                                        mRlJudge.setVisibility(View.VISIBLE);
                                    }
                                }
                            }
                        } else mSmartLayout.finishRefresh(false);
                    } catch (JSONException e) {
                        mSmartLayout.finishRefresh(false);
                        e.printStackTrace();
                    }
                } else {
                    mSmartLayout.finishRefresh(false);
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }


    private void showTopCaiPan(boolean show) {
        mRecyclerViewMain.setVisibility(show ? View.VISIBLE : View.GONE);
        mLlNoMainJudge.setVisibility(!show ? View.VISIBLE : View.GONE);
    }

    private void showCaiPan(boolean show) {
        mRecyclerView.setVisibility(show ? View.VISIBLE : View.GONE);
        mLlNoJudge.setVisibility(!show ? View.VISIBLE : View.GONE);
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        OkHttpUtils.getInstance().cancelTag(this);
    }
}
